// pages/edu/component/tabbar/index.js
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    active:{
      type:Number,
      value:1
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    tabList:[
      '/pages/index/index',
      '/edu/pages/index/index/index',
      '/edu/pages/exam/index/index',
      '/edu/pages/my/index/index'
    ]
  },

  /**
   * 组件的方法列表
   */
  methods: {
    onChange(event){
      let active=event.detail
      let tabList=this.data.tabList
      if(active==0){
        wx.switchTab({
          url:tabList[0]
        })
      }else{
        let currentPage= getCurrentPages()
        let url=currentPage[currentPage.length-1].route
        if(active==1&&url==tabList[1]){
          return;
        }
        if(active==1){
          wx.reLaunch({
            url: tabList[active]
          })
          return;
        }
        wx.navigateTo({
          url:tabList[active]
        })
      }
      console.log(event.detail)
    }
  }
})
